package com.zb.test;

import org.junit.Test;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;

/**
 *  TemporalAdjuster:时间校正器
 *  TemporalAdjuster：该类通过静态方法提供了大量的常用TemporalAdjuster的实现
 */
public class JAVA8_14_TemporalAdjuster {
    @Test
    public void test1(){
        //设置日期设置在当前月的10号
        LocalDate localDate = LocalDate.now();
        LocalDate localDate1 = localDate.withDayOfMonth(10);
        System.out.println(localDate1);

        //用时间校正器设置
        LocalDate localDate2 = localDate.with(TemporalAdjusters.next(DayOfWeek.SATURDAY));//设置在周六
        System.out.println(localDate2);

        //设置生日
        //可以接受一个函数类型的函数式接口，可以做更多的操作
        LocalDate localDate3 = localDate.with(TemporalAdjusters.ofDateAdjuster((x) -> {
            return LocalDate.of(2018,8,24);
        }));
        System.out.println(localDate3);

    }

}
